package com.problem.leetcode;

/**
 * @author didi
 * @DESCRIPTION
 * @create 2019-06-03 13:36
 **/

public class Problem507 {
    public boolean checkPerfectNumber(int num) {

        if (num == 0) {
            return false;
        }

        boolean result = false;
        int     sum    = 0;
        for (int index = 1; num > (index * index); index++) {
            if (index == 1) {
                sum += index;
            } else {
                if (num % index == 0) {
                    sum += index;
                    sum += (num) / index;
                }
            }
        }

        if (sum == num) {
            result = true;
        }

        return result;
    }
}
